package o;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import com.huawei.appgallery.forum.base.card.bean.Section;
import com.huawei.appgallery.foundation.card.gamereserve.bean.OrderAppCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appmarket.service.reserve.game.bean.ReserveResponse;
import java.lang.ref.WeakReference;
import o.ewm.n;

class dkj {

    static class d implements efe {
        private Context ˋ;
        private boolean ˎ;
        private WeakReference<CardBean> ˏ;
        private dkf ॱ;

        d(dkf o_dkf, CardBean cardBean, boolean z, Context context) {
            this.ॱ = o_dkf;
            this.ˏ = new WeakReference(cardBean);
            this.ˎ = z;
            this.ˋ = context;
        }

        public void ˋ() {
            this.ॱ.ॱ();
        }

        public void ˎ(BaseRequest o_cvu, ResponseBean responseBean) {
            if ((responseBean instanceof ReserveResponse) && (o_cvu instanceof efc)) {
                ReserveResponse reserveResponse = (ReserveResponse) responseBean;
                efc o_efc = (efc) o_cvu;
                Object ˋ = reserveResponse.ˋ();
                String ˋ2 = o_efc.ˋ();
                if (!TextUtils.isEmpty(ˋ) && ˋ.equals(ˋ2)) {
                    bwx o_bwx = (bwx) fho.ˏ().ˋ("Operation").ॱ(bwx.class);
                    Section section = new Section();
                    section.ॱ(reserveResponse.ʽ());
                    ˋ2 = ((bus) fho.ˏ().ˋ("Forum").ॱ(bus.class)).ˎ();
                    CardBean cardBean;
                    if (this.ˎ) {
                        if (reserveResponse.getResponseCode() == 0 && (reserveResponse.getRtnCode_() == 101004 || reserveResponse.getRtnCode_() == 101001)) {
                            ll.ˏ(ContentManager.getInstant().getContext()).ˋ(new Intent("ACTION_RESERVE"));
                            ॱ();
                            cardBean = (CardBean) this.ˏ.get();
                            if (cardBean instanceof OrderAppCardBean) {
                                ((OrderAppCardBean) cardBean).ˏॱ(1);
                                o_bwx.ॱ(this.ˋ, section, 0, ˋ2);
                                brd.ॱ.ˊ(ˋ2, bqy.ˋ().ˎ(this.ˋ), section.ˊ(), "APPRESERVE", 1);
                            }
                        }
                    } else if (reserveResponse.getResponseCode() == 0 && (reserveResponse.getRtnCode_() == 101005 || reserveResponse.getRtnCode_() == 101006)) {
                        ll.ˏ(ContentManager.getInstant().getContext()).ˋ(new Intent("ACTION_CANCEL_RESERVE"));
                        cardBean = (CardBean) this.ˏ.get();
                        if (cardBean instanceof OrderAppCardBean) {
                            ((OrderAppCardBean) cardBean).ˏॱ(0);
                            o_bwx.ॱ(this.ˋ, section, 1, ˋ2);
                            brd.ॱ.ˊ(ˋ2, bqy.ˋ().ˎ(this.ˋ), section.ˊ(), "APPRESERVE", 0);
                        }
                    }
                }
            }
            this.ॱ.ॱ();
        }

        private void ॱ() {
            CharSequence ˋ;
            if (eqp.ᐝ()) {
                ˋ = NetWorkUtil.getWifiResId(this.ˋ, n.יˏ);
            } else {
                ˋ = this.ˋ.getString(n.ˉʼ);
            }
            evk.ॱ(ˋ, 0).ˋ();
        }
    }

    dkj() {
    }

    protected void ॱ(Context context, String str, CardBean cardBean, dkf o_dkf) {
        if (TextUtils.isEmpty(str)) {
            Logger.e("GameReserveUtil", "reserve, packageName = " + str);
        } else {
            efb.ॱ().ˋ(context, str, o_dkf, new d(o_dkf, cardBean, true, context));
        }
    }

    void ˊ(Context context, String str, CardBean cardBean, dkf o_dkf) {
        if (TextUtils.isEmpty(str)) {
            Logger.e("GameReserveUtil", "cancelReserve, packageName = " + str);
        } else {
            efb.ॱ().ˏ(context, str, o_dkf, new d(o_dkf, cardBean, false, context));
        }
    }
}
